package com.atguigu.edustats.controller;


import com.atguigu.commonutils.R;
import com.atguigu.edustats.service.DailyService;
import com.atguigu.servicebase.handler.GuliException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author ryan
 * @since 2021-11-02
 */
@RestController
@RequestMapping("/edustats/daily")
//@CrossOrigin
public class DailyController {
    @Autowired
    private DailyService dailyService;

    //统计某一天注册人数
    @PostMapping("/createStatisticsByDay/{day}")
    public R createStatisticsByDay(@PathVariable String day) throws GuliException {
        dailyService.createStatisticsByDay(day);
        return R.ok();
    }

    //图表显示，返回两部分数据，日期json数组，数量json数组
    @GetMapping("/showData/{type}/{begin}/{end}")
    public R showData(@PathVariable String type,@PathVariable String begin,@PathVariable String end){
        Map<String,Object> map = dailyService.getShowData(type,begin,end);
        return R.ok().data(map);
    }

    @GetMapping("/mock/camera/{cameraId}")
    public R mockCamera(@PathVariable String cameraId){
        HashMap<String, Object> config = new HashMap<>();
        config.put("cameraIPAddress", "rtsp://admin:ivlab2019@192.168.104.233//Streaming/Channels/1");
        config.put("uploadAddress", "http://192.168.240.102:7102/fws-core/event/add");
        config.put("gateRegion1", "14 291 5 555 28 561 103 281");
        config.put("cameraId", cameraId);
        return R.ok().data(config);
    }

}

